package com.tanhua.server.interceptor;

import com.tanhua.domain.db.User;

public class UserHolder {
    private static ThreadLocal<User> userThreadLocal=new ThreadLocal<User>();
    //向当前线程存入用户
    public static void setUser(User user){
        userThreadLocal.set(user);
    }
    //从当前线程获取用户
    public static User getUser(){
       return userThreadLocal.get();
    }
    //获取当前用户的id
    public static Long getUserId(){
        return userThreadLocal.get().getId();
    }
}
